package com.ciwong.epaper.ui;

import android.app.Activity;
import android.os.Bundle;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.method.LinkMovementMethod;
import android.text.style.URLSpan;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.TextView;

import com.ciwong.epaper.R;
import com.ciwong.epaper.util.ALiYunManager;
import com.ciwong.epaper.util.EJumpManager;
import com.ciwong.libs.utils.CWSys;
import com.ciwong.libs.utils.volley.BaseRequest;
import com.ciwong.mobilelib.i.ViewOnClickListener;

/**
 * 个人信息保护指引页面
 * Created by paul on 2023/12/06.
 */
public class FirstAgreementActivity extends Activity {
    private static final String TAG = "FirstAgreementActivity";
    private TextView tx_use_url, tx_secret_url, tx_child_url;
    private Button btn_go_black, btn_go_main;
    private String packageName = "";
    private BaseRequest.VerifyInfo verifyInfo;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_agreement_layout);
        findViews();
        initEvent();
        init();
    }

    private void findViews() {
        tx_use_url = findViewById(R.id.tx_use_url);
        tx_secret_url = findViewById(R.id.tx_secret_url);
        tx_child_url = findViewById(R.id.tx_child_url);
        btn_go_black = findViewById(R.id.btn_go_black);
        btn_go_main = findViewById(R.id.btn_go_main);
    }

    private void initEvent() {
        tx_use_url.setMovementMethod(LinkMovementMethod.getInstance());
        tx_secret_url.setMovementMethod(LinkMovementMethod.getInstance());
        tx_child_url.setMovementMethod(LinkMovementMethod.getInstance());

        btn_go_black.setOnClickListener(myOnClickListener);
        btn_go_main.setOnClickListener(myOnClickListener);
    }

    private void init() {
        packageName = getPackageName();
    }

    /**
     * 点击按钮
     *
     * @author res-jxliu
     */
    private ViewOnClickListener myOnClickListener = new ViewOnClickListener() {
        @Override
        public void avertRepeatOnClick(View v) {
            int vId = v.getId();
            if (vId == com.ciwong.mobilelib.R.id.btn_go_black) {
                finish();
            } else if (vId == com.ciwong.mobilelib.R.id.btn_go_main) {
                ALiYunManager.initInstance(getApplicationContext());
                try {
                    CWSys.setSharedBoolean("isFirstUse" + packageName, false);//以后都不再是第一次使用
                    CWSys.setSharedBoolean("agreement" + packageName, true);//以后都不再显示同意
                } catch (Exception e) {
                    e.printStackTrace();
                }
                //跳转新手引导
                //EJumpManager.jumpToGuide(0, AgreementActivity.this);
                EJumpManager.jumpToLogin(0, FirstAgreementActivity.this);
            }
        }
    };

    @Override
    public void onResume() {
        super.onResume();
    }
}
